{% extends "base.html" %}

{% block content %}

<div class="row">
	<div class="span8 columns">
		<h1 class="inline">{{ dish.name }} </h1><h3 class="inline">at <a href="/{{ urls.PLACE }}/{{ dish.place.slug }}">{{ dish.place.name }}</a></h3>
	</div>
</div>

<div class="row">
	<div class="span12 columns">
		<div>
		<a href="/{{ urls.ADD_REVIEW }}/{{ dish.id }}" class="btn primary">Add Review</a>
		<a href="/rate/{{ dish.id }}/good" class="btn small">Like</a>
		<a href="/rate/{{ dish.id }}/bad" class="btn small">Dislike</a>
		
		{{ dish.users_voted_good.count }} likes,
		{{ dish.users_voted_bad.count }} dislikes
		
		
		</div>
		<p>
			{% if dish.photos %}
			<ul>
				{% for photo in dish.photos.all %}
				<li class="inline">
					<a href="/media/{{ photo.display.url }}"><img src="/media/{{ photo.thumbnail.url }}" class="imagedropshadow" /></a>
				</li>
				{% endfor %}
			</ul>
			{% endif %}
		</p>

		<p>
			{% with num_reviews=dish.review_set.count %}
				<h3>{{ num_reviews }} Review{{ num_reviews|pluralize }}</h3>
			{% endwith %}
			
			{% if reviews_by_user %}
				<div class="alert-message block-message warning"> 
					{% with num_reviews=reviews_by_user.count %}
						<p><strong>Your Review{{ num_reviews|pluralize }}</strong></p>
					{% endwith %}
					<ul>
						{% for rev in reviews_by_user %}
							<li>{{ rev.date_added }} by <a href="/{{ urls.PROFILE }}/{{ rev.profile.user.username }}">{{ rev.profile.user.username }}</a> - {{ rev.text }}
							<a href="/{{ urls.EDIT_REVIEW }}/{{ rev.id }}"> edit</a></li>
						{% endfor %}
					</ul>
				</div>
			{% endif %}

			{% if dish.review_set %}
				<ul>
					{% for rev in dish.review_set.all %}
						<li>{{ rev.date_added }} by <a href="/{{ urls.PROFILE }}/{{ rev.profile.user.username }}">{{ rev.profile.user.username }}</a> - {{ rev.text }}</li>
					{% endfor %}
				</ul>
			{% endif %}
		</p>

	</div>
</div>

{% endblock %}